home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disk User Volume 3 #9
/
Commodore_Disk_User_Vol.3_9_1990_-.d64
/
aw-text storage
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
5KB
|
144 lines
10 rem ********************************
15 rem * adventure writing on the c64 *
20 rem * *
25 rem * written by jason finch *
30 rem * (c) cdu 1990 *
35 rem ********************************
40 :
45 poke53280,14:poke53281,6:print"[147][142] please insert disk that can"
50 print" be formatted (device eight)"
55 print,"[157][157]and then press 'return'":poke198,0
60 geta$:ifa$<>chr$(13)then60
65 print"[145] are you sure about that??? [y/n]":poke198,0
70 geta$:ifa$="n"then45
75 ifa$<>"y"then70
80 :
85 rem ******************************
90 rem * display introductory info. *
95 rem ******************************
100 :
105 restore:print"[147]the following descriptions will now be"
110 print"saved, first to individual sectors which";
115 print"will be allocated as used and then as"
120 print"separate sequential files:"
125 fori=1to5:readd$(i):printd$(i)"":next
130 print"please wait: formatting the disk..."
135 :
140 rem *******************************
145 rem * format disk & check errors *
150 rem *******************************
155 :
160 open15,8,15,"n0:aw-storage demo,aw":gosub655:close15:ifethen660
165 print"[147]ok. saving descriptions to sectors zero thro' four on track one:"
170 :
175 rem *******************************
180 rem * open channels to disk drive *
185 rem * and set write track and *
190 rem * sector to one *
195 rem *******************************
200 :
205 open15,8,15:open8,8,8,"#":tr=1:sr=0
210 :
215 rem *******************************
220 rem * send information to buffer *
225 rem *******************************
230 :
235 fors=1to5:d$=d$(s):printd$"":print#15,"b-p 8 0"
240 forl=1tolen(d$):print#8,mid$(d$,l,1);:next:print#8,chr$(0);
245 print#15,"b-a 0";tr;sr:t(s)=tr:s(s)=sr:rem *** check block allocation
250 :
255 rem *******************************
260 rem * check error/block avail'bty *
265 rem *******************************
270 gosub655:ife=0then340
275 ife=66thentr=tr+1:sr=0:goto245
280 ife<>65thenclose8:close15:goto660:rem *** some other disk error
285 ifb=0thenclose8:close15:print"disk full":end:rem *** all blocks used
290 :
295 rem *******************************
300 rem * chosen block was already *
305 rem * used. variables b/c from *
310 rem * error checking hold next *
315 rem * free sector location info. *
320 rem * so set new tr/sr and re-try *
325 rem *******************************
330 :
335 tr=b:sr=c:goto245
340 print#15,"u2 8 0";tr;sr: rem *** write sector information
345 :
350 rem *******************************
355 rem * increment sector pointer *
360 rem * then repeat for five loc'ns *
365 rem *******************************
370 :
375 sr=sr+1:next:close8:close15
380 :
385 rem *******************************
390 rem * all stored: do as seq.files *
395 rem *******************************
400 :
405 print"[147]ok. saving as separate sequential files called loc1,loc2,...,loc5:"
410 fors=1to5:d$=d$(s):printd$""
415 open2,8,1,"@0:loc"+mid$(str$(s),2)+",s,w":rem *** open sequential file
420 forl=1tolen(d$):print#2,mid$(d$,l,1);:next:rem *** send information
425 print#2,chr$(0);:close2:next
430 :
435 rem *******************************
440 rem * all stored: do as seq.files *
445 rem *******************************
450 :
455 print"[147]ok - all saved. now press a numeric"
460 print"key from one to five. that description"
465 print"will then be retrieved first from the"
470 print"individual sector and then from its sequential file...":poke198,0
475 getk$:ifk$<"1"ork$>"5"then475
480 :
485 rem *******************************
490 rem * open channels for direct *
495 rem * access commands and check *
500 rem * for disk errors *
505 rem *******************************
510 :
515 k=val(k$):open15,8,15:open8,8,8,"#":gosub655:ifethenclose8:close15:goto660
520 print#15,"u1 8 0";t(k);s(k):rem *** read track/sector to buffer
525 get#8,a$:ifa$=""then535
530 printa$;:goto525:rem *** loop back for more
535 close8:close15:print""
540 :
545 rem *******************************
550 rem * have read direct-now seq'tl *
555 rem *******************************
560 :
565 open2,8,0,"loc"+mid$(str$(k),2)+",s,r":rem *** open sequential file
570 get#2,a$:ifa$=""then615
575 printa$;:goto570:rem *** loop back for more
580 :
585 rem *******************************
590 rem * both forms have been *
595 rem * recalled. wait for keypress *
600 rem * to return and repeat. *
605 rem *******************************
610 :
615 close2:print:print"press any key for another..."
620 poke198,0:wait198,1:poke198,0:print"[147]for another description press a numeric"
625 goto460:rem *** go back and wait for another keypress
630 :
635 rem *******************************
640 rem * read disk error channel *
645 rem *******************************
650 :
655 input#15,e,a$,b,c:return
660 print"[147] disk error! [146]",,," "a$" @"b"[157],"c:print" press a key":poke198,0
665 wait198,1:poke198,0:goto45
670 :
675 rem *******************************
680 rem * data statements for simple *
685 rem * description information *
690 rem *******************************
695 :
700 data"you are standing on a stony path that runs up the side of the hill."
705 data"inside the small cabin you notice a chest on the eastern wall."
710 data"you are on a muddy path leading down to a fast flowing river."
715 data"the forest has become much more dense onthis side of the river."
720 data"you are standing in the middle of a large clearing in the woods."